<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/vue.js"></script>

</head>
<body>

<div id="div1">
    <!--绑定样式
        内联样式style属性的使用
    -->
   <div v-bind:style="{border:border1,width:border_width,height:border_heigth}">测试1</div>

    <!--通过对象-->
   <div v-bind:style="objSty">测试2</div>

    <!--通过属性-->
   <div v-bind:style="[objSty,objSty2]">测试3</div>





    <button @click="handler">修改样式</button>

</div>

<script>

    const vueObj = new Vue({
        el:'#div1',
        data: {
            border1: '5px solid red',
            border_width: '200px',
            border_heigth: '200px',

            //通过对象封装样式
            objSty: {
                border: '5px solid green ',
                width: '200px',
                height: '200px',

            },
            objSty2: {
                border: '3px solid pink ',   //在测试3中覆盖了objSty的样式
                backgroundColor: 'green',


            }

        },
        methods:{
            //点击修改样式
            handler:function(){
                this.border_width = '500px';
                this.border_heigth = '500px';
                this.objSty2.backgroundColor = 'blue';

            },
        }
    });
</script>
</body>
</html>